home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 21 / AACD 21.iso / AACD / Utilities / Ghostscript / src / ibnum.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-01-01  |  2.5 KB  |  67 lines

  1. /* Copyright (C) 1990, 1996, 1997 Aladdin Enterprises.  All rights reserved.
  2.   
  3.   This file is part of AFPL Ghostscript.
  4.   
  5.   AFPL Ghostscript is distributed with NO WARRANTY OF ANY KIND.  No author or
  6.   distributor accepts any responsibility for the consequences of using it, or
  7.   for whether it serves any particular purpose or works at all, unless he or
  8.   she says so in writing.  Refer to the Aladdin Free Public License (the
  9.   "License") for full details.
  10.   
  11.   Every copy of AFPL Ghostscript must include a copy of the License, normally
  12.   in a plain ASCII text file named PUBLIC.  The License grants you the right
  13.   to copy, modify and redistribute AFPL Ghostscript, but only under certain
  14.   conditions described in the License.  Among other things, the License
  15.   requires that the copyright notice and this notice be preserved on all
  16.   copies.
  17. */
  18.  
  19. /*$Id: ibnum.h,v 1.2 2000/09/19 19:00:41 lpd Exp $ */
  20. /* Encoded number definitions and support */
  21. /* Requires stream.h */
  22.  
  23. #ifndef ibnum_INCLUDED
  24. #  define ibnum_INCLUDED
  25.  
  26. /* Define the byte that begins an encoded number string. */
  27. /* (This is the same as the value of bt_num_array in btoken.h.) */
  28. #define bt_num_array_value 149
  29.  
  30. /* Homogenous number array formats. */
  31. /* The default for numbers is big-endian. */
  32. #define num_int32 0        /* [0..31] */
  33. #define num_int16 32        /* [32..47] */
  34. #define num_float 48
  35. #define num_float_IEEE num_float
  36. #define num_float_native (num_float + 1)
  37. #define num_msb 0
  38. #define num_lsb 128
  39. #define num_is_lsb(format) ((format) >= num_lsb)
  40. #define num_is_valid(format) (((format) & 127) <= 49)
  41. /* Special "format" for reading from an array. */
  42. /* num_msb/lsb is not used in this case. */
  43. #define num_array 256
  44. /* Define the number of bytes for a given format of encoded number. */
  45. extern const byte enc_num_bytes[];    /* in ibnum.c */
  46.  
  47. #define enc_num_bytes_values\
  48.   4, 4, 2, 4, 0, 0, 0, 0,\
  49.   4, 4, 2, 4, 0, 0, 0, 0,\
  50.   sizeof(ref)
  51. #define encoded_number_bytes(format)\
  52.   (enc_num_bytes[(format) >> 4])
  53.  
  54. /* Read from an array or encoded number string. */
  55. int num_array_format(P1(const ref *));    /* returns format or error */
  56. uint num_array_size(P2(const ref *, int));
  57. int num_array_get(P4(const ref *, int, uint, ref *));
  58.  
  59. /* Decode a number from a string with appropriate byte swapping. */
  60. int sdecode_number(P3(const byte *, int, ref *));
  61. int sdecodeshort(P2(const byte *, int));
  62. uint sdecodeushort(P2(const byte *, int));
  63. long sdecodelong(P2(const byte *, int));
  64. float sdecodefloat(P2(const byte *, int));
  65.  
  66. #endif /* ibnum_INCLUDED */
  67.